package stackexchange.analyzer;

import static stackexchange.Constants.PROC_OF_USERS;

import java.util.Vector;

import stackexchange.User;
import stackexchange.UserGroup;
import stackexchange.posts.Answer;
import stackexchange.posts.Question;

public class AnswerAnalyzer implements ExpertAnalyzer {


	@Override
	public UserGroup analyze(UserGroup userGroup, Vector<Question> questions,
			Vector<Answer> answers) {
		Vector<User> allUsers = userGroup.getUsers();
		for (int i = 1; i < allUsers.size(); i++) {
			allUsers.get(i).setExpertiseScore(allUsers.get(i).getUsersAnswers().size());
		}
		// sort
		UserGroup allUsersGroup =
//				return 
						new UserGroup(allUsers)
				.sortOnExpertiseScore();
		Vector<User> sortedUsers = allUsersGroup.getUsers();
		// take %? procent of users
		Vector<User> expertUsers = new Vector<User>();
		for (int i = 0; i < allUsers.size() * PROC_OF_USERS; i++) {
			System.out.println(sortedUsers.get(i));
			expertUsers.add(sortedUsers.get(i));
		}
		return new UserGroup(expertUsers);
	}

}
